<template>
  <div>
    <el-form ref="dataForm" :model="dataForm" :rules="dataRule" label-width="120px">
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item size="mini" label="主键" prop="Id">
            <el-input v-model="dataForm.Id" maxlength="25" show-word-limit placeholder="请输入主键" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商表主键" prop="Supplier_pid">
            <el-input v-model="dataForm.Supplier_pid" maxlength="25" show-word-limit placeholder="请输入供应商表主键" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商名称" prop="Supplier_name">
            <el-input v-model="dataForm.Supplier_name" maxlength="25" show-word-limit placeholder="请输入供应商名称" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商联系人" prop="Supplier_connecter">
            <el-input v-model="dataForm.Supplier_connecter" maxlength="25" show-word-limit placeholder="请输入供应商联系人" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商联系人职位" prop="Supplier_position">
            <el-input v-model="dataForm.Supplier_position" maxlength="25" show-word-limit placeholder="请输入供应商联系人职位" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商联系人电话" prop="Supplier_phone">
            <el-input v-model="dataForm.Supplier_phone" maxlength="25" show-word-limit placeholder="请输入供应商联系人电话" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商联系人邮箱" prop="Supplier_mail">
            <el-input v-model="dataForm.Supplier_mail" maxlength="25" show-word-limit placeholder="请输入供应商联系人邮箱" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="供应商推荐识别码" prop="Recommand_code">
            <el-input v-model="dataForm.Recommand_code" maxlength="25" show-word-limit placeholder="请输入供应商推荐识别码" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="推荐原因" prop="Recommand_reason">
            <el-input v-model="dataForm.Recommand_reason" maxlength="25" show-word-limit placeholder="请输入推荐原因" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="推荐供应商类型" prop="Supplier_type">
            <el-input v-model="dataForm.Supplier_type" maxlength="25" show-word-limit placeholder="请输入推荐供应商类型" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="推荐部门" prop="Recommand_dept">
            <el-input v-model="dataForm.Recommand_dept" maxlength="25" show-word-limit placeholder="请输入推荐部门" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="推荐人" prop="Recommander">
            <el-input v-model="dataForm.Recommander" maxlength="25" show-word-limit placeholder="请输入推荐人" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="采购部负责人" prop="Supplier">
            <el-input v-model="dataForm.Supplier" maxlength="25" show-word-limit placeholder="请输入采购部负责人" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="undefined" prop="Updater">
            <el-input v-model="dataForm.Updater" maxlength="25" show-word-limit placeholder="请输入undefined" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="undefined" prop="Creater">
            <el-input v-model="dataForm.Creater" maxlength="25" show-word-limit placeholder="请输入undefined" />
          </el-form-item>
        </el-col><el-col :span="12">
          <el-form-item size="mini" label="undefined" prop="Isdeleted">
            <el-input v-model="dataForm.Isdeleted" maxlength="25" show-word-limit placeholder="请输入undefined" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row>
      <el-col style="text-align: right;">
        <el-button size="mini" icon="el-icon-close" @click="visible = false">取消</el-button>
        <el-button size="mini" icon="el-icon-check" type="primary" @click="dataFormSubmit()">确定</el-button>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import { getRecommend, saveRecommend, updateRecommend} from '@/api/recommend'
  export default {
    props: ['Id'],
    data() {
      return {
        dataForm: {
           Id: '',
           Supplier_pid: '',
           Supplier_name: '',
           Supplier_connecter: '',
           Supplier_position: '',
           Supplier_phone: '',
           Supplier_mail: '',
           Recommand_code: '',
           Recommand_reason: '',
           Supplier_type: '',
           Recommand_dept: '',
           Recommander: '',
           Supplier: '',
           Updater: '',
           Creater: '',
           Isdeleted: '',
          
        },
        dataRule:{
           Id: '',
           Supplier_pid: '',
           Supplier_name: '',
           Supplier_connecter: '',
           Supplier_position: '',
           Supplier_phone: '',
           Supplier_mail: '',
           Recommand_code: '',
           Recommand_reason: '',
           Supplier_type: '',
           Recommand_dept: '',
           Recommander: '',
           Supplier: '',
           Updatedate: '',
           Updater: '',
           Createdate: '',
           Creater: '',
           Isdeleted: '',
          
        }
      }
    },
    mounted(){
      if(this.Id && this.Id > 0) {
        this.init()
      }
    },
    methods: {
      init() {
        let _this = this
        _this.$refs.dataForm.resetFields()
        if(_this.Id && this.Id > 0) {
          getRecommend(_this.Id).then( (data) => {
            if (data && data.code === '20000'){
              _this.dataForm = data.Recommend
            }
          })
        }else{

        }
      },
      cancel(){
        this.$emit("closeable")
      },
      dataFormSubmit(){
        var permission
        if (this.Id && this.Id > 0) {
          permission = updateRecommend(this.dataForm)
        } else {
          permission = saveRecommend(this.dataForm)
        }
        permission.then((data) => {
          if (data && data.code === '20000') {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.$emit('closeable')
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    }
  }
</script>
>
